package com.xx.job.controller.system;


import com.xx.job.common.Result;
import com.xx.job.controller.dto.PageDTO;
import com.xx.job.entity.system.SysPost;
import com.xx.job.service.system.SysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import com.xx.job.controller.base.BaseController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liangcy
 * @since 2021-01-14
 */
@RestController
@RequestMapping("/api/v1")
public class SysPostController extends BaseController {
    @Autowired
    private SysPostService sysPostService;

    @RequestMapping("/postlist")
    public Result postlist(PageDTO pageDTO, SysPost sysPost){
        return Result.success(sysPostService.selectPagePost(pageDTO,sysPost));
    }

    @PostMapping("/post")
    public Result addPost(@RequestBody SysPost sysPost){
        return Result.success(sysPostService.add(sysPost));
    }

    @GetMapping("/post/{id}")
    public Result selectPost(@PathVariable Long id){
        return Result.success(sysPostService.select(id));
    }

    @DeleteMapping("/post/{id}")
    public Result deletePost(@PathVariable Long id){
        return Result.success(sysPostService.delete(id));
    }

    @PutMapping("/post")
    public Result updatePost(@RequestBody SysPost sysPost){
        return Result.success(sysPostService.update(sysPost));
    }



}

